# -*- coding: utf-8 -*-
# @Time    : 2022/5/24 21:10
# @Author  : leijiu
# @Email   : 517711635@qq.com
# @File    : add_goods_page.py
# @Software: PyCharm
"""
添加商品页面
"""
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
from page.base_page import BasePage
class AddGoodsPage(BasePage):
    # def __init__(self,driver):
    #     self.driver=driver

    #添加、编辑商品定位器
    ele_goodsname_locator = (By.NAME, "goods_name")
    ele_goodstype_locator = (By.CSS_SELECTOR, "#general-table > tbody > tr:nth-child(3) > td:nth-child(2) > select")
    ele_goodsprice_locator = (By.NAME, "shop_price")
    ele_addgoodsbtn_locator = (By.CSS_SELECTOR, "#tabbody-div > form > div > input:nth-child(2)")

        #输入商品名称
    def goodsname(self):
        self.driver.find_element(*self.ele_goodsname_locator).clear()
        self.driver.find_element(*self.ele_goodsname_locator).send_keys("天子")
        # 商品类型选择
    def goodstype(self):
        goodstype_element = self.driver.find_element(*self.ele_goodstype_locator)
        goodstype_select_obj = Select(goodstype_element)
        goodstype_select_obj.select_by_visible_text("    裤子")
        # 输入商品售价
    def goodsprice(self):
        self.driver.find_element(*self.ele_goodsprice_locator).clear()
        self.driver.find_element(*self.ele_goodsprice_locator).send_keys("112")
        # 点击确定
    def addgoodsbtn(self):
        self.driver.find_element(*self.ele_addgoodsbtn_locator).click()